﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    var parentId = $.request("parentId");
    var categoryId = $.request("categoryId");

    $(function () {
        initControl();
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/SysOrganize/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        } else {
            $("#ParentId").val(parentId).trigger("change"); //默认选中
            switch (categoryId) {
                case "Company":
                    $("#CategoryId").val("Department").trigger("change");
                    break;
                case "Department":
                    $("#CategoryId").val("Work").trigger("change");
                    break;
                case "Work":
                    $("#CategoryId").val("Work").trigger("change");
                    //$("#CategoryId").prop("disabled", true);
                    break;
            }
        }
    });
    function initControl() {
        $("#CategoryId").select2({ minimumResultsForSearch: -1 });
        $("#ParentId").bindSelect({
            url: "/SystemManage/SysOrganize/GetTreeSelectJson"
        });
    }
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var submitUrl = "Insert";
        if (!!keyValue) {
            submitUrl = "Update";
        }
        $.submitForm({
            url: "/SystemManage/SysOrganize/" + submitUrl + "?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
        return false;
    }
</script>
<form id="form1">
    <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#home" data-toggle="tab">基本信息</a>
            </li>
            <li><a href="#extend" data-toggle="tab">扩展信息</a></li>
        </ul>
        <div class="tab-pane fade in active" id="home">
            <table class="form">
                <tr>
                    <th class="formTitle">上级</th>
                    <td class="formValue Value">
                        <select id="ParentId" name="ParentId" class="form-control required">
                            <option value="0">父节点</option>
                        </select>
                    </td>
                    <th class="formTitle">类型</th>
                    <td class="formValue Value">
                        <select id="CategoryId" name="Target" class="form-control required">
                            <option value="">请选择</option>
                            @*<option value="Company">集团</option>*@
                            <option value="Company">公司</option>
                            <option value="Department">部门</option>
                            @*<option value="Work">小组</option>*@
                            <option value="Work">岗位</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">名称</th>
                    <td class="formValue Value">
                        <input id="FullName" name="FullName" type="text" class="form-control required" placeholder="请输入名称" />
                    </td>
                    <th class="formTitle">编号</th>
                    <td class="formValue Value">
                        <input id="EnCode" name="EnCode" type="text" class="form-control required" placeholder="请输入编号" />
                    </td>
                </tr>
                <tr>
                <tr>
                    <th class="formTitle">负责人</th>
                    <td class="formValue Value">
                        <input id="ManagerId" name="Managerid" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">手机</th>
                    <td class="formValue Value">
                        <input id="MobilePhone" name="MobilePhone" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">微信</th>
                    <td class="formValue Value">
                        <input id="WeChat" name="Managerid" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">电话</th>
                    <td class="formValue Value">
                        <input id="TelePhone" name="TelePhone" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>

                    <th class="formTitle">邮箱</th>
                    <td class="formValue Value">
                        <input id="Email" name="MobilePhone" type="text" class="form-control" />
                    </td>
                    <th class="formTitle">传真</th>
                    <td class="formValue Value">
                        <input id="Fax" name="MobilePhone" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">地址</th>
                    <td class="formValue Value" colspan="3">
                        <input id="Address" name="address" type="text" class="form-control" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle" style="height: 35px;">选项</th>
                    <td class="formValue Value" colspan="3" style="padding-top: 1px;">
                        <div class="ckbox">
                            <input id="EnabledMark" name="EnabledMark" type="checkbox" checked="checked"><label for="EnabledMark">有效</label>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle" valign="top" style="padding-top: 5px;">
                        备注
                    </th>
                    <td class="formValue Value" colspan="3">
                        <textarea id="Description" name="Descriptions" class="form-control" style="height: 60px;"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <div class="tab-pane fade" id="extend">
            @*<iframe Name="_pos" src="/SystemManage/SysPosition/Index"></iframe>*@

        </div>
    </div>
</form>
